<?php
class Kajedugbenjol_model extends CI_Model{
var $gallery_path;
	function   __construct() {
        parent::__construct();
    }

        function Cari_pesan()
	{
	    $q = $this->db->query("SELECT pesan from inpormasi");
	    return $q;

    }
	  function edit($id,$detail)
	{
		
		$data = array(
            'pesan' => $detail,
		);
		$this->db->where('id', $id);
        $this->db->update('inpormasi', $data);
    }
      function potonya($gambare)
	{
    	$config['upload_path'] = './images/info/';

		$config['allowed_types'] = 'gif|jpg|png|bmp|jpeg';

		$config['max_size'] = '20000';

		$config['max_width'] = '1024';

		$config['max_height'] = '768';

		$this->load->library('upload',$config);
		$this->upload->initialize($config);

		if(!$this->upload->do_upload('poto')) {

        $flashdata = $this->upload->display_errors();

    	$this->session->set_userdata('poto', $flashdata);

	}
}
function get_images(){
$this->gallery_path = realpath(APPPATH . '../images/info/');
//gallery_path = realpath(APPPATH . '../images/info/');
$this->gallery_path_url = base_url().'images/info/';
$files = scandir($this->gallery_path);
$files = array_diff($files, array('.','..','thumbs'));
 
$images = array();
 
foreach ($files as $file) {
$images[] = array(
'url' => $this->gallery_path_url . $file,
'namafile'=> $file,);
}
 
return $images;
}
function delete($mana)
   {
//   echo 'base_url()'$mana;
   unlink('./images/info/'.$mana);
   }	
}
?>
